public class Demo3 {
    public static void main(String[] args) {
        Object locker = new Object();

        Thread thread1 = new Thread(() -> {
            synchronized(locker) {//拿到locker
                try {
                    locker.wait();//释放锁locker
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName());
        });

        Thread thread2 = new Thread(() -> {
            synchronized (locker) {//拿到锁locker
                locker.notify();//唤醒thread1
                System.out.println(Thread.currentThread().getName());
            }
        });

        thread1.start();
        thread2.start();
    }
}
